package com.zhouyu.user.service;

import com.zhouyu.springframework.*;

@Component
@Transactional
public class UserService implements BeanNameAware, ApplicationContextAware ,InitializingBean,UserInterface{

    @Autowired
    private OrderService orderService;

    private ZhouyuApplicationContext applicationContext;
    private String beanName;

    public void test(){
        /*System.out.println(orderService);
        System.out.println(applicationContext);
        System.out.println(beanName);*/
        System.out.println("执行userService的test()方法");
    }

    /**
     * 回调接口，注入配置文件
     *
     * @param applicationContext
     */
    @Override
    public void setApplicationContext(ZhouyuApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    /**
     * 回调接口，注入bean的名称
     *
     * @param name
     */
    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }

    /**
     * 初始化
     */
    @Override
    public void afterPropertiesSet() {
        System.out.println("初始化");
    }
}
